package hl.crazy_java.chapter_6;

/**
 * 
 * @author Liu Huan
 */

abstract class SpeedMeter {
    private double turnRate;
    public SpeedMeter(){}
    public abstract double calGirth();

    public void setTurnRate(double turnRate) {
        this.turnRate = turnRate;
    }
    public double getSpeed() {
        return calGirth()*turnRate;
    }
}

class CarSpeedMeter extends SpeedMeter {
    private double radius;
    public CarSpeedMeter(double radius) {
        this.radius = radius;
    }

    @Override
    public double calGirth() {
        return 2*radius;
    }
}

public class SpeedMeterTest {
    public static void main(String[] args) {
        var cs = new CarSpeedMeter(4);
        cs.setTurnRate(10);
        System.out.println(cs.getSpeed());
    }
}
